package com.turato.json.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.turato.json.model.dto.TestRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tuhao
 * @date 2020/11/25 3:12 下午
 * @desc
 */
@RestController
@Controller
public class  JsonController {

    @RequestMapping(value = "/json")
    public String receiveJson(@RequestBody TestRequest request) {
        System.out.println(request);
        //jsonObject 未被解析出来
        return request.toString();
    }

    @RequestMapping(value = "/fastjson")
    public String receiveJson(@RequestBody JSONObject request) {
        System.out.println(request);
        //全部解析出来
        return request.toString();
    }

    @RequestMapping(value = "/gson")
    public String receiveJson(@RequestBody Object request) {
        System.out.println(request);
        //全部能解析出来
        return request.toString();
    }

    @RequestMapping(value = "/jackson")
    public String receiveJson(@RequestBody JsonNode request) {
        System.out.println(request);
        //全部能解析出来
        return request.toString();
    }

}
